package pen_exam.xieceng_2023_11_20;

import java.util.Scanner;

public class Class01_NumCount {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] s1 = sc.nextLine().split(" ");
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(s1[i]);
        }
        int L = 0;
        int R = 0;
        int num = 0;
        while(L <= R && R < n){
            while (R < n && arr[L] == arr[R]  ){
                R ++;
                num++;
            }
            if(num >1){
                System.out.print(arr[L] + "(" + num + ")" + " ");
            }else{
                System.out.print(arr[L] + " ");
            }
            L = R;
            num = 0;
        }

    }
}
